import request from "@/utils/request";

// 审核模板
export function templateList(data) {
  return request({
    url: "/base/flow/template/page",
    method: "get",
    params: { pageNum: 1, pageSize: 999, ...data },
  });
}
// 撤销流程（仅进行中的任务支持撤回 ）
export function rescinded(data) {
  return request({
    url: "/base/flow/task/rescinded?id=" + data,
    method: "post",
    // params: data,
  });
}
// 流程 实例 详情
export function taskDetail(data) {
  return request({
    url: "/base/flow/task/detail",
    method: "get",
    params: data,
  });
}


// 个人基本资料所有 用户列表
export function getUserList(query) {
  return request({
    url: "/base/auth/user/page",
    method: "get",
    params: { pageSize: 20, ...query },
  });
}

// 查询厂级 公司
export function getGrids(query) {
  return request({
    url: "/base/org/list",
    method: "get",
    params: { parentId: 1, type: 2 },
  });
}

// 查询部门 （来源基础数据）
export function getDicts() {
  return request({
    url: "/base/datascope/depts",
    method: "get",
  });
}

// 查询班组（来源基础数据）
export function getTeams(data) {
  return request({
    url: "/base/datascope/teams",
    method: "get",
    params: {deptIds: data ? data.join(',') : ''},
  });
}

// 班组类型
export function getListByCode() {
  return request({
    url: "/base/data/dict/getListByCode?code=bzlx",
    method: "get",
  });
}

// 班组人员（来源基础数据）
export function getTeamUserList(data) {
  return new Promise((e) => {
    request({
      url: "/business/team/group/dict/member",
      method: "post",
      data: data,
    }).then(({ result }) => {
      let promise = result.map((item) => ({ ...item, id: item.memberId }));
      e({ result: promise });
    });
  });
}

// 部门人员（来源基础数据）1
export function getPageMember(data) {
  return request({
    url: "/business/dept/team/manage/pageMember",
    method: "post",
    data: { ...data, pageNum: 1, pageSize: 300 },
  });
}

// 部门人员（来源基础数据）2
export function getPageMemberList(data) {
  return request({
    url: "/business/dept/team/manage/dict",
    method: "post",
    data: data,
  });
}

// 部门人员详情（来源基础数据）
export function getUserInfor(data) {
  return request({
    url: "/base/auth/user/getUser/" + data,
    method: "get",
  });
}

// 上传文件
export function upload(file, createUserId) {
  let formData = new FormData();

  formData.append("file", file);
  formData.append("createUserId", createUserId);
  return request({
    url: "/base/file/upload",
    method: "post",
    data: formData,
  });
}

// 查询 选择人员（来源个人基本资料）组件内部使用
export function getUserListElement(data) {
  return request({
    url: "/base/auth/user/page",
    method: "get",
    params: data,
  });
}

// 查询 承包商列表
export function orgList(data) {
  return request({
    url: "/business/contractor/data/manage/list",
    method: "post",
    data: data || {},
  });
}

// 查询 承包商全部项目列表
export function getProjectList() {
  return request({
    url: "/business/contractor/project/manage/list",
    method: "post",
    data: {
      opinionStatus: 1,
    },
  });
}
// 查询 承包商下人员列表
export function getOrgUserList(contractorId, projectId) {
  return request({
    url: "/business/contractor/projectPeople/manage/list",
    method: "post",
    data: {
      contractorId: contractorId,
      projectId: projectId,
    },
  });
}
